package com.team6.yygh.hosp.controller;

import com.team6.yygh.hosp.service.HospitalService;
import com.team6.yygh.model.hosp.Hospital;
import com.team6.yygh.result.Result;
import com.team6.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @ClassName HospitalController
 * @Author ZhuYouWan
 * @Date 2022/10/20 13:49
 **/
@Api(tags = "医院管理接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    /**
     * 医院列表
     */
    @ApiOperation(value = "获取医院列表")
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page, @PathVariable Integer limit, HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pageModel = hospitalService.selectHospPage(page, limit, hospitalQueryVo);
        return Result.ok(pageModel);
    }

    /**
     * 更新医院上线状态
     */
    @ApiOperation(value = "更新医院上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result updateHospitalStatus(@PathVariable String id, @PathVariable Integer status){
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    /**
     * 医院详情信息
     */
    @ApiOperation(value = "医院详情信息")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id){
        Map<String, Object> map = hospitalService.getHospById(id);
        return Result.ok(map);
    }
}
